package com.atguigu.srb.core.controller.admin;


import com.atguigu.srb.common.result.R;
import com.atguigu.srb.core.pojo.entity.UserInfo;
import com.atguigu.srb.core.pojo.query.UserInfoQuery;
import com.atguigu.srb.core.service.UserInfoService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 用户基本信息 前端控制器
 * </p>
 *
 * @author fan
 * @since 2021-11-22
 */

@Api(tags = "后台用户管理系统")
@RestController
@RequestMapping("/admin/core/userInfo")

public class AdminUserInfoController {

   @Resource
   private UserInfoService userInfoService;
   @ApiOperation("分页功能")
   @GetMapping("/list/{page}/{limit}")
   public R getUserInfoList(@PathVariable("page") Long page,@PathVariable("limit") Long limit, UserInfoQuery userInfoQuery){
      Page<UserInfo> pageModel = userInfoService.pageList(page,limit,userInfoQuery);
      return R.ok().data("pageModel",pageModel);
   }
   @ApiOperation("状态修改功能")
   @GetMapping("/lock/{id}/{status}")
   public R lockUserInfoStatus(@PathVariable("id") String id,@PathVariable("status") Integer status){
      Integer statusChange = userInfoService.lockUserInfoStatus(id,status);
      //响应status纯属多余了；写业务时想着能不能在页面直接给前端status赋值并刷新按钮显示、从而不用再次查询列表
      return R.ok().data("status",statusChange);
   }


}

